/**
 * 用于上传图片loading
 * @param imageList 图片集合
 * @param arg app响应图片字段名
 * @param maxCount 最大可上传数
 */

export const handleImageUpdate = (imageList: Array<any>, arg: {sign: string,url: string,name: string }, maxCount: number) => {
    if (!imageList || maxCount === undefined) {
        console.warn(`Unsupported image type: ${arg.name}`);
        return;
    }
    if (imageList.length < maxCount && !arg.url) {
        imageList.push({ sign: arg.sign, url: arg.url });
    } else if (imageList.length < maxCount + 1 && arg.url) {
        for (const item of imageList) {
            if (item.sign === arg.sign) {
                item.url = arg.url;
                break;
            }
        }
    }
}